using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using UIProcessSchemaObjects;

namespace UIProcessActivities
{
    [Designer(typeof(CopyFormResourceValuesDesigner), typeof(IDesigner))]
    public partial class CopyFormResourceValues : SequenceActivity
	{
		public CopyFormResourceValues()
		{
			InitializeComponent();
		}

        public static DependencyProperty SourceFormProperty = System.Workflow.ComponentModel.DependencyProperty.Register("SourceForm", typeof(UIProcessSchemaObjects.Form), typeof(CopyFormResourceValues));

        [Description("Source Form to copy value from")]
        [Category("Input")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public UIProcessSchemaObjects.Form SourceForm
        {
            get
            {
                return ((UIProcessSchemaObjects.Form)(base.GetValue(CopyFormResourceValues.SourceFormProperty)));
            }
            set
            {
                base.SetValue(CopyFormResourceValues.SourceFormProperty, value);
            }
        }

        public static DependencyProperty SourceFormResourceProperty = System.Workflow.ComponentModel.DependencyProperty.Register("SourceFormResource", typeof(string), typeof(CopyFormResourceValues));

        [Description("Form Resource Name to copy value from")]
        [Category("Input")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string SourceFormResource
        {
            get
            {
                return ((string)(base.GetValue(CopyFormResourceValues.SourceFormResourceProperty)));
            }
            set
            {
                base.SetValue(CopyFormResourceValues.SourceFormResourceProperty, value);
            }
        }

        public static DependencyProperty SourceFieldNameProperty = System.Workflow.ComponentModel.DependencyProperty.Register("SourceFieldName", typeof(string), typeof(CopyFormResourceValues));

        [Description("Form Resource Field Name to copy value from")]
        [Category("Input")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string SourceFieldName
        {
            get
            {
                return ((string)(base.GetValue(CopyFormResourceValues.SourceFieldNameProperty)));
            }
            set
            {
                base.SetValue(CopyFormResourceValues.SourceFieldNameProperty, value);
            }
        }

        public static DependencyProperty DestinationFormProperty = System.Workflow.ComponentModel.DependencyProperty.Register("DestinationForm", typeof(UIProcessSchemaObjects.Form), typeof(CopyFormResourceValues));

        [Description("Form to copy value to")]
        [Category("Input")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public UIProcessSchemaObjects.Form DestinationForm
        {
            get
            {
                return ((UIProcessSchemaObjects.Form)(base.GetValue(CopyFormResourceValues.DestinationFormProperty)));
            }
            set
            {
                base.SetValue(CopyFormResourceValues.DestinationFormProperty, value);
            }
        }

        public static DependencyProperty DestinationFormResourceProperty = System.Workflow.ComponentModel.DependencyProperty.Register("DestinationFormResource", typeof(string), typeof(CopyFormResourceValues));

        [Description("Form Resource to copy value to")]
        [Category("Input")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string DestinationFormResource
        {
            get
            {
                return ((string)(base.GetValue(CopyFormResourceValues.DestinationFormResourceProperty)));
            }
            set
            {
                base.SetValue(CopyFormResourceValues.DestinationFormResourceProperty, value);
            }
        }

        public static DependencyProperty DestinationFieldNameProperty = System.Workflow.ComponentModel.DependencyProperty.Register("DestinationFieldName", typeof(string), typeof(CopyFormResourceValues));

        [Description("Name of the field to copy the value to")]
        [Category("Input")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string DestinationFieldName
        {
            get
            {
                return ((string)(base.GetValue(CopyFormResourceValues.DestinationFieldNameProperty)));
            }
            set
            {
                base.SetValue(CopyFormResourceValues.DestinationFieldNameProperty, value);
            }
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            string strValue = FormHelper.FindFormResourceValue(this.SourceForm, this.SourceFormResource, this.SourceFieldName);
            FormHelper.SetFormResourceValue(this.DestinationForm, this.DestinationFormResource, this.DestinationFieldName, strValue);

            return ActivityExecutionStatus.Closed;
        }
    }
}
